#232: Make all endpoints async#256
Merged
Kilo59 merged 23 commits intoExpDev07:masterfrom Apr 3, 2020
Merged
Conversation
These are required to be able to test asyncio functionality, as well as making ASGI test clients play nice asynchronously.
- Move test fixtures into tests/fixtures.py - Update test fixtures to mock aiohttp.ClientSession.get, instead of requests.get - Add a context manager to replace the global httputils.client_session with an AsyncMock - Misc. cleanup
I didn't see this file when I first added the new fixtures.
One can still define a separate responder function here, but since this is the only response defined for the tests thus far, this seems like a reasonable default.
Contributor
Author
|
Builds are currently failing for 3.6 and 3.7, I wrote this PR under 3.8 - looks like some of the async test fixtures are new in the standard lib as of 3.7 and 3.8. I'll take a look for backport options for these. |
07e4074 to
99ea07e
Compare
Using these as decorators causes a lot of problems when combined with Pytest fixtures, often resulting in the mock not applying.
Kilo59
reviewed
Apr 3, 2020
| [dev-packages] | ||
| async-asgi-testclient = "*" | ||
| async_generator = "*" | ||
| asyncmock = "*" |
Collaborator
There was a problem hiding this comment.
These back-ports should be adjusted so that they are only installed when required.
https://pipenv.readthedocs.io/en/latest/basics/#specifying-versions-of-a-package
https://pipenv.readthedocs.io/en/latest/advanced/#specifying-basically-anything
I'll try to do this tonight if I have a chance.
Thanks for all the notes, should make this easy.
Collaborator
|
@all-contributors please add @james-gray for code |
Contributor
|
I've put up a pull request to add @james-gray! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch adds async support to all API endpoints to make them non-blocking, using
asyncioandaiohttp.aiohttpto make the two requests for data sources instead of requests, as requests is not compatible withasyncioA key piece of this is the addition of a globalaiohttp.ClientSessioninstance, which exists for the entire application run.ClientSession.Added dependencies:
#232
(Reopening this on my personal GH account to avoid authorship confusion.)